import { User } from "../../../modeal/user.js"
const user = new User()
Page({

  data: {
    coupons: [],
    page: 1,
    isMore: false
  },

  onLoad: function (options) {
    this.getMyCoupons(); // 获取我所有的优惠券
  },

  onReady: function () { },
  onShow: function () { },

  onReachBottom: function () {
    this.getMyCoupons();
  },

  // 获取我所有优惠卷
  getMyCoupons () {
    let page = this.data.page
    user.getMyCouponAll(page).then(res => {
      if (res.length >= 1) {
        this.setData({
          coupons: this.data.coupons.concat(res),
          page: page + 1,
          isMore: true,
        })
        res.length < 10 ? this.setData({ isMore: false }) : ''
      }
    })
  },

  

})